/*
 * Copyright 2016 Wealth Inc. All rights reserved.
 */
 package com.wealth.commodity.service;

import java.util.List;
import java.util.Map;

import org.springframework.data.domain.Page;
import org.springframework.web.multipart.MultipartFile;

import com.wealth.commodity.entity.Goods;
import com.wealth.commodity.vo.FloorGoodsVO;
import com.wealth.commodity.vo.GoodsVO;
import com.wealth.order.entity.OrderPlat;

import iaas.service.IBaseService;
import iaas.web.JqGridRequest;

/**
 * @author chan
 * @version 1.0
 * @since 1.0
 */
 
public interface IGoodsService extends IBaseService<Goods>{
	
	/** ---------------- 后台 ---------------- */
	/** 保存商品 */
	public void saveGoods(Goods goods) throws Exception;
	
	/** 修改商品 */
	public void updateGoods(Goods goods) throws Exception;
	
	/** 批量保存商品 */
	public boolean importFile(MultipartFile file,Long category) throws Exception;
	
	/** 查询商品  商户*/
	public Page<Goods> getAllByMerchantId(Long merchantid, JqGridRequest request) throws Exception;
	
	/** 检查商品库存  */
	public boolean checkInventory(Goods goods, Integer amount) throws Exception;
	
	/** 减少商品库存 */
	public boolean decreaseRemain(Long id, Integer amount) throws Exception;
	
	/** 增加商品销量 */
	public void increaseSales(Long id, Integer amount) throws Exception;
	
	/** ---------------- 微信端 ---------------- */
	//查询某分类下状态为上架的商品
	public List<GoodsVO>  getPag (Long categoryId , Integer status,Long marketId) throws Exception;
		
	//查询某分类下状态为上架的商品(加载更多)
	public List<GoodsVO> getPagMore (Long id,Long categoryId , Integer status,Long marketId) throws Exception;
	
	/** 
	 * 查询商品 市场+状态
	 * 按销量排序
	 * 微信端 -> 惠生活首页
	 */
	public List<Goods> getGoodsByMerchantMarketIdAndStatus (Long marketid , Integer status) throws Exception;
	
	/** 
	 * 查询商品 商户+状态 
	 * 微信端 -> 惠生活商户详情
	 */
	public List<Goods> getGoodsByMerchantIdAndStatus (Long merchantid , Integer status) throws Exception;
	
	/**
	 * 查询商品 特价
	 * 微信端 -> 首页
	 */
	public List<Goods> getCheapGoodsList(Long corpid, Integer index, Integer offset) throws Exception;
		

		
	/**
	 * 商品分页
	 * @param sortno 数据集最后一个ID
	 * @param offset 查找几条
	 * @param goods
	 * @return
	 */
	public Page<Goods> getGoodsApi(Integer sortno,Integer offset,Goods goods)throws Exception;
	
	
	/**
	 * 限天超商品分页
	 * @param sortno 数据集最后一个ID
	 * @param offset 查找几条
	 * @param goods
	 * @return
	 */
	public Page<Goods> getGoodsXTCApi(Integer sortno,Integer offset,Integer type,Goods goods)throws Exception;
	 
 
	//商品详情
	public GoodsVO getGoods(Long goodsId) throws Exception;
	
	//商品主页
	public List<Goods> findTop12ByCategoryIdAndStatusOrderBySalesDesc(Long marketid, Integer status);
	
	//条件查询商品
	public List<GoodsVO> findByStatusAndNameLike(Integer status,Long categoryId,String name,Long marketId) throws Exception;
	
	//条件查询商品(主页面模糊查询商品)
	public List<GoodsVO> findByStatusAndNameLike(Integer status,String name,Long marketId,Long Id) throws Exception;
	
	
	//特价商品
	public List<Goods> findCheapGoods(Long id,Integer ischeap,Integer status);
	
	//查询折扣商品
	public List<Goods> findDiscountGoods(Long id, Integer ischeap,Integer status);
	
	//查询免立减商品
	public List<Goods> findFullcutGoods(Long id, Integer ischeap,Integer status,Long merchantId);
	
	//查询某商户的打折商品
	public List<GoodsVO> findByMerchantIdAndIsDiscountAndStatus(Long maxId,Long merchantId,Integer isDiscount,Integer status);

	public List<Goods> ajaxHuiLife(Long marketId, Integer status, String name);
	
	public List<Goods> ajaxGoodsVO(Long marketid, Long categoryid,
			Long districtid, Integer isParentCategory, Integer status,
			Integer index, Integer offset);
	
	
	//删除商品之前的图片
	public void deletePics(Long goodsid)  throws Exception;

	public List<GoodsVO> getDownPag (Integer status,Long marketId,Integer Id) throws Exception;
	
	//pc端商品列表分页查询
	
	//pc端商品列表
	public Map<String,Object>  getGoodsByCategoryId(); 
	/**
	 * 商品列表的分页查询
	 * @param pageNumber 第几页
 	 * @param pageSize 一页显示条数
	 * @param sortType 排序字段
	 * @param sortDirection 排序方向
	 * @param categoryId 商品分类Id
	 * @return
	 */
	public  Map<String,Object> getGoodsPag( int pageNumber, int pageSize,
			String sortType, String sortDirection,Long categoryId);
	
	/**查询所有的商品*/
	public List<FloorGoodsVO> getGoodsAllForFloor(Integer status) throws Exception;
	//商品列表分页查询
	public Map<String,Object>  getGoods( int pageNumber, int pageSize,
			String sortType,String sortDirection,String name,String categoryId);
	
	/**
	 * 验证商品是否下架
	 * @param orderPlat
	 * @return
	 */
	public boolean checkIsDown(OrderPlat orderPlat);
	
	
	/**
	 * 验证购买的商品是否超过限额
	 * @param orderPlat
	 * @return
	 */
	public boolean checkPurRestrictions(OrderPlat orderPlat);
}
